#include <iostream>
#include <string.h>

using namespace std;

bool Increment(char* str){

    int length = strlen(str);
    bool isOverFlow = false;
    int takeOver = 0;

    for ( int i = length -1 ; i>=0; i-- ){
        int nums = str[i] - '0' + takeOver;
        // 个位数需要加１
        if ( i == (length-1) ){
            nums ++;
        }

        if ( nums >= 10 ){
            if ( i == 0 ){
                // 会溢出
                isOverFlow = true;
            }else {
                takeOver = nums /10;
                str[i] = '0' + nums%10;
            }
        }else {
            str[i] = '0' + nums%10;
            break;
        }
    }
    return isOverFlow;
}

void printStr(char * str ){
    // 数字首位是否为0
    bool isbegin0 = true;

    int length = strlen(str);
    for ( int i = 0 ; i < length ; i++ ){
        if ( str[i] != '0' && isbegin0 ){
            isbegin0 = false;
        }

        if ( !isbegin0 ){
            printf("%c", str[i]);
        }
    }
    printf("\n");
}

void Print1ToMaxNDigits(int n){
    if ( n < 0 )
        return ;

    // 字符串末尾会自动添加\0, 因此需要多声明n+1空间大小
    char * str = new char[n+1];
    memset(str, '0', n);
    str[n] = '\0';

    while(!Increment(str)){
        printStr(str);
    }

}

int main(void){
    Print1ToMaxNDigits(6);
    return 0;
}